import { useAxios } from '@/hooks/web/useAxios'
const request = useAxios()

// 获取所有字典
export const getDictApi = () => {
  return request.get({ url: '/dict/list' })
}

// 模拟获取某个字典
export const getDictOneApi = () => {
  return request.get({ url: '/dict/one' })
}

export const getDictionary = (data) => {
  return request.postXww({ url: 'user/dictionary/getDictionary', data })
}

// 【保存】新增编辑字典值
export const saveDicValue = (data) => {
  return request.post({
    url: 'user/dicValue/saveOrUpdateDicValue',
    data
  })
}

// 【刪除】刪除字典值
export const delDicValue = (data) => {
  return request.delete({
    url: `user/dicValue/deleteDicValue/${data}`,
    headersType: 'application/x-www-form-urlencoded'
  })
}

/**
 *@author lxc
 *@description:根据dicId查出相应的信息
 *@param:
 *@date: 2022-06-15 14:45:35
 **/
export const getDicValue = (pkId) => {
  return request.postXww({
    url: 'user/dicValue/get',
    data: { pkId: pkId }
  })
}

/**
 * @description 获取文本对应的及拼音
 * @author Elwin ZHANG
 * @date 2023-03-21 09:56
 */
export const getPinyin = (text: string, maxLength: number) => {
  return request.postXww({
    url: 'user/tools/getPinyin',
    data: { text: text, maxLength: maxLength }
  })
}
/**
 * @description 获取文本对应的简体中文及拼音
 * @author Elwin ZHANG
 * @date 2023-03-21 09:56
 */
export const getZhCNAndPinyin = (text: string, maxLength: number) => {
  return request.postXww({
    url: 'user/tools/getZhCNAndPinyin',
    data: { text: text, maxLength: maxLength }
  })
}

/**
 * @description 获取文本对应的简体中文及拼音
 * @author Elwin ZHANG
 * @date 2023-03-21 09:56
 */
export const getZhHKAndPinyin = (text: string, maxLength: number) => {
  return request.postXww({
    url: 'user/tools/getZhHKAndPinyin',
    data: { text: text, maxLength: maxLength }
  })
}
